public class demo2 {
    int sum;
    int target;
    public int findTargetSumWays(int[] nums, int _target) {
        target=_target;
        dfs(nums,0,0);
        return sum;
    }
    public void dfs(int[]nums,int path,int temp){
        if(nums.length==path) {
            if (temp == target) {
                sum++;
            }
            return;
        }
        dfs(nums,path+1,temp+nums[path]);
        dfs(nums,path+1,temp-nums[path]);
    }
}
